package com.bestcem.xm.member.entity.pojo;

import com.bestcem.xm.member.entity.mysql.SyncRuleEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;

/**
 * 同步规则数据访问对象
 *
 * @author qiongyu.cui <qiongyu.cui@idiaoyan.com>
 * @version 1.0
 * @date 2021/9/23 10:38
 */
@Getter
@Setter
@ToString
public class SyncRuleDO {
    /**
     * 主键
     */
    private String syncruleId;

    /**
     * 组织标识
     */
    private String orgId;

    /**
     * 联系人类型 0-个人联系人 1-机构联系人 2-内部联系人 3-隐藏的 4-项目
     */
    private Integer memberType;

    /**
     * 联系人类型 0-个人联系人 1-机构联系人 2-内部联系人 3-隐藏的 4-项目
     */
    private Integer type;

    /**
     * 微信同步类型 0 同步 1 不同步
     */
    private Integer wechatSyncEnabled;

    /**
     * 匹配字段列表
     */
    private String queryFields;

    /**
     * 更新字段列表
     */
    private String updateFields;

    /**
     * 创建时间(北京时间)
     */
    private Date createTime;

    /**
     * 更新时间(北京时间)
     */
    private Date updateTime;

    /**
     * SyncRuleDo to SyncRuleEntity
     *
     * @param syncRuleDo
     * @return
     */
    public static SyncRuleEntity toEntity(SyncRuleDO syncRuleDo) {
        SyncRuleEntity entity = new SyncRuleEntity();
        entity.setCreateTime(syncRuleDo.getCreateTime());
        entity.setMemberType(syncRuleDo.getMemberType());
        entity.setOrgId(syncRuleDo.getOrgId());
        entity.setQueryFields(syncRuleDo.getQueryFields());
        entity.setSyncruleId(syncRuleDo.getSyncruleId());
        entity.setType(syncRuleDo.getType());
        entity.setUpdateFields(syncRuleDo.getUpdateFields());
        entity.setUpdateTime(syncRuleDo.getUpdateTime());
        entity.setWechatSyncEnabled(syncRuleDo.getWechatSyncEnabled());
        return entity;
    }

    /**
     * SyncRuleEntity to SyncRuleDo
     *
     * @param ruleEntity
     * @return
     */
    public static SyncRuleDO toDo(SyncRuleEntity ruleEntity) {
        SyncRuleDO syncRuleDo = new SyncRuleDO();
        syncRuleDo.setCreateTime(ruleEntity.getCreateTime());
        syncRuleDo.setMemberType(ruleEntity.getMemberType());
        syncRuleDo.setOrgId(ruleEntity.getOrgId());
        syncRuleDo.setQueryFields(ruleEntity.getQueryFields());
        syncRuleDo.setSyncruleId(ruleEntity.getSyncruleId());
        syncRuleDo.setType(ruleEntity.getType());
        syncRuleDo.setUpdateFields(ruleEntity.getUpdateFields());
        syncRuleDo.setUpdateTime(ruleEntity.getUpdateTime());
        syncRuleDo.setWechatSyncEnabled(ruleEntity.getWechatSyncEnabled());
        return syncRuleDo;
    }
}
